package cn.com.elite;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class LoriThread implements Runnable{
	private static final Log log=LogFactory.getLog(LoriThread.class);
	private boolean flag=true; //停止线程标记 
	public static String dotime;
	public static com.elitecrm.service.coresync.CoreSyncService coreSyncService;
	private String judge_daytime="";
	
	public String getDotime() {
		return dotime;
	}

	public void setDotime(String dotime) {
		this.dotime = dotime;
	}
	public void run(){
		log.info("－－－－－－－－－－－－－－－－－－－LoriThread（372）－－－－－－－－－－－－－－－－－－");
		while(flag){
			try{
				Date date=new Date();
				String nowtime=String.format("%tR",date); //获取现在几点
				String daytime=String.format("%tF",date);
				log.debug("LoriThread_nowtime:"+nowtime);
				nowtime=nowtime.substring(0,2);
				log.debug("LoriThread_nowtime_pro:"+nowtime);
				log.debug("LoriThread_judge_daytime:"+judge_daytime);
				log.debug("LoriThread_daytime:"+daytime);
				String dotime1=ISPayServlet.ebean.chaxunString1();
				log.debug("LoriThread_dotime1:"+dotime1);
				if(nowtime.equals(dotime1)){
					coreSyncService.syncCore(); 
					judge_daytime=daytime;
				}
			}catch(Exception e){
				log.error("run():"+Util.getERRO(e));
			}        
			try{
				log.debug("时间未到，休眠59分");
            	Thread.sleep(59*60*1000);
            }catch(Exception e){
            	log.error("定时错误:"+Util.getERRO(e)); 
            }
		}
	}
}
